package com.framework.loippi.utils;

import java.util.HashMap;
import java.util.Map;

public class APIReturnJson {

    public static String jsonString(String message, Object data, int status)

    {
        Map returnMap = new HashMap();
        returnMap.put("message", message);
        returnMap.put("data", data);
        returnMap.put("status", status);

        return JacksonUtil.toJson(returnMap);
    }

    public static String jsonString(String message, Object data, int status, String[] excludes)

    {
        Map returnMap = new HashMap();
        returnMap.put("message", message);
        returnMap.put("data", data);
        returnMap.put("status", status);

        return JacksonUtil.toJson(returnMap);
    }

    public static String jsonString(String message, int status)

    {
        Map returnMap = new HashMap();
        returnMap.put("message", message);
        returnMap.put("status", status);

        return JacksonUtil.toJson(returnMap);
    }

    public static String jsonStringError(String message, int status)

    {
        Map returnMap = new HashMap();
        returnMap.put("message", message);
        returnMap.put("status", status);

        return JacksonUtil.toJson(returnMap);
    }

    public static String error(Object obj) {
        Map returnMap = new HashMap();
        APIXerror aPIXerrorEnum = APIXerror.valueOf(obj.toString());
        returnMap.put("message", aPIXerrorEnum.massage);
        returnMap.put("status", aPIXerrorEnum.xCode);
        returnMap.put("data", "");
        return JacksonUtil.toJson(returnMap);
    }

    public static String success() {
        Map returnMap = new HashMap();
        returnMap.put("message", "ok");
        returnMap.put("status", 2000000);
        return JacksonUtil.toJson(returnMap);
    }

    public static String success(Object obj) {
        Map returnMap = new HashMap();
        returnMap.put("message", "ok");
        returnMap.put("data", obj);
        returnMap.put("status", 2000000);
        return JacksonUtil.toJson(returnMap);
    }
    /*public static void main(String[] args) {
		APIXerrorEnum s = APIXerrorEnum.LOGIN_ACCOUNT_DISABLED;
		//System.out.println(s);
		//System.out.println(APIXerrorEnum.valueOf(s.toString()).massage);
		//System.out.println(error(APIXerrorEnum.LOGIN_ACCOUNT_DISABLED));
		//System.out.println(APIXerrorEnum.valueOf(APIXerrorEnum.LOGIN_ACCOUNT_DISABLED.massage));
	}*/
}
